﻿// MyNotes - Free Sticky Notes
// Copyright (C) 2011 Alexandre Vicenzi
// 
// This program is free software; you can redistribute it and/or modify it under 
// the terms of the GNU General Public License as published by the Free Software 
// Foundation; either version 3 of the License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful, but WITHOUT 
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with 
// this program; if not, write to the Free Software Foundation, Inc., 
// 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace MyNotes
{
    public enum AnnotationType { Text = 0, Image = 1, Web = 2 }

    [Serializable]
    class Annotation
    {
        private AnnotationType type;
        private string text;
        private NoteColor color;
        private bool locked;
        private Point location;
        private Size size;
        private DateTime creation;
        private DateTime modification;
        private DateTime exclusion;
        private bool visible;
        [NonSerialized]
        private FrmNotes formNote = null;

        public Annotation(AnnotationType type, string text, NoteColor color, bool locked, Point location, Size size)
        {
            Type = type;
            Text = text;
            Color = color;
            Locked = locked;
            Location = location;
            FormSize = size;
            creation = DateTime.Now;
            ModificationTime = DateTime.Now;
            Visible = true;
            CreateForm(this);
            Notes.AddAnnotation(this);
        }

        public Annotation(AnnotationType type, NoteColor color)
        {
            Type = type;
            Text = "";
            Color = color;
            Locked = false;
            Location = new Point(0, 0);
            FormSize = new Size(195, 165);
            creation = DateTime.Now;
            ModificationTime = DateTime.Now;
            Visible = true;
            CreateForm(this);
            Notes.AddAnnotation(this);
        }

        public void CreateForm()
        {
            CreateForm(this);
        }

        private void CreateForm(Annotation note)
        {
            this.formNote = new FrmNotes();
            this.formNote.SetAnnotation(note);
            this.formNote.LoadParameters();
            this.formNote.Visible = this.Visible;
        }

        public void DisposeAnnotation()
        {
            this.formNote.Dispose();
        }

        public AnnotationType Type
        {
            get { return type; }
            set { type = value; }
        }

        public string Text
        {
            get { return text; }
            set { text = value; }
        }

        public NoteColor Color
        {
            get { return color; }
            set { color = value; }
        }

        public bool Locked
        {
            get { return locked; }
            set { locked = value; }
        }

        public Point Location
        {
            get { return location; }
            set { location = value; }
        }

        public Size FormSize
        {
            get { return size; }
            set { size = value; }
        }

        public DateTime CreationTime
        {
            get { return creation; }
            //set { creation = value; }
        }

        public DateTime ModificationTime
        {
            get { return modification; }
            set { modification = value; }
        }

        public DateTime ExclusionTime
        {
            get { return exclusion; }
            set { exclusion = value; }
        }

        public bool Visible
        {
            get { return visible; }
            set { visible = value; }
        }
    }
}
